package com.kehutong.payment.errcode;

import org.coraframework.json.JSONObject;
import org.coraframework.util.IntHashMap;
import com.kehutong.common.errcode.ErrorCode;

public enum PayErrorCode {

    OK(200, "请求成功"),
    E215001(215001, "请检查必填参数后重试")
    ;
    private static final IntHashMap<ErrorCode> map;

    static {
        IntHashMap<ErrorCode> current = new IntHashMap<ErrorCode>(530);
        for (ErrorCode code : ErrorCode.values()) {
            current.put(code.code, code);
        }
        map = current;
    }

    public final int code;
    public final String message;

    private PayErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ErrorCode of(int code) {
        return map.get(code);
    }

    public static ErrorCode of(JSONObject jsonObject, String name) {
        return map.get(jsonObject.getIntValue(name));
    }
}
